<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="../../component/pear/css/pear.css" />
    <style>

    </style>
</head>

<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <div class="layui-form-item layui-inline">订单号:</div>
                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" name="orderNo"  placeholder="请输入搜索内容" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">用户名:</div>
                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" name="userName"  placeholder="请输入搜索内容" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">支付方式:</div>
                <div class="layui-form-item layui-inline">

                    <div>
                        <select name="payType" lay-verify="" style="width: 200px;">
                            <option value="">请选择支付方式</option>
                            <option value="1">余额</option>
                            <option value="2">微信</option>
                            <option value="3">支付宝</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-inline">订单类型:</div>
                <div class="layui-form-item layui-inline">
                    <div>
                        <select name="orderType" lay-verify="" style="width: 200px;">
                            <option value="">请选择订单类型</option>
                            <option value="1">转账</option>
                            <option value="2">一对一红包</option>
                            <option value="3">群拼手气红包</option>
                            <option value="4">充值</option>
                            <option value="5">提现</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-inline">订单交易状态:</div>
                <div class="layui-form-item layui-inline">
                    <div>
                        <select name="status" lay-verify="" style="width: 200px;">
                            <option value="">请选类型交易状态</option>
                            <option value="0">初始化</option>
                            <option value="1">成功</option>
                            <option value="2">进行状态</option>
                            <option value="3">交易完成(</option>
                            <option value="4">交易取消</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-inline">开始日期:</div>
                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="startTime" placeholder="请选择日期">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">结束日期:</div>
                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="endTime" placeholder="请选择日期">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="yhxx-query">
                        <i class="layui-icon layui-icon-search"></i>
                        搜索
                    </button>
                </div>

            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="yhxx-table" lay-filter="yhxx-table"></table>
    </div>
</div>
<script type="text/html" id="startTime_tpl">
    {{layui.util.toDateString(d.startTime, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<script type="text/html" id="endTime-tpl">
    {{layui.util.toDateString(d.endTime, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<!--<script type="text/html" id="yhxx-bar">
    <button class="pear-btn pear-btn-sm" lay-event="retract">撤回</button>
</script>-->

<script type="text/html" id="avatar-tpl">
    <img src="{{d.avatar}}"/>
</script>

<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
    layui.use(['table', 'laydate', 'form', 'jquery'], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        var laydate = layui.laydate;

        //年月选择器
        laydate.render({
            elem: '#startTime'

        });
        laydate.render({
            elem: '#endTime',
            min:$("#startTime").val()
        });

        let cols = [
            [{
                type: 'checkbox'
            },
                {
                    title: '序号',
                    field: 'id',
                    align: 'center',
                    width: 100
                },
                {
                    title: '订单编号',
                    field: 'orderNo',
                    align: 'center'
                },
                {
                    title: '用户',
                    field: 'userName',
                    align: 'center'
        /*            templet: function (data) {
                        if (data.type == 0) {
                            return '<span>单聊</span>'
                        } else if (data.type == 1) {
                            return '<span>群聊</span>'
                        } else if (data.type == 2) {
                            return '<span>聊天室</span>'
                        } else {
                            return '<span>频道</span>'
                        }*/

                },
                {
                    title: '订单类型',
                    field: 'orderType',
                    align: 'center',

                },
                {
                    title: '支付类型',
                    field: 'payType',
                    align: 'center',
                },
                {
                    title: '收支情况',
                    field: 'balance',
                    align: 'center',
                },
                {
                    title: '订单总金额',
                    field: 'amount',
                    align: 'center',
                },
                {
                    title: '留言',
                    field: 'note',
                    align: 'center',
                },
                {
                    title: '订单状态',
                    field: 'status',
                    align: 'center',
                },
                {
                    title: '开始时间',
                    field: 'startTime',
                    align: 'center',
                    templet: "#startTime_tpl"
                },
                {
                    title: '结束时间',
                    field: 'endTime',
                    align: 'center',
                    templet: "#endTime-tpl"
                },
                {
                    title: '创建时间',
                    field: 'createTime',
                    align: 'center',
                    templet: "#createTime-tpl"
                },
                {
                    title: '操作',
                    toolbar: '#yhxx-bar',
                    align: 'center',
                    width: 130
                }
            ]
        ]

        table.render({
            elem: '#yhxx-table',
            url: '/api/order/select',
            page: true,
            cols: cols,
            skin: 'line',
            toolbar: '#yhxx-toolbar',
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter', 'print', 'exports']
        });

        table.on('tool(yhxx-table)', function (obj) {
            if (obj.event === 'remove') {
                window.remove(obj);
            } else if (obj.event === 'retract') {
                window.retract(obj);
            }
        });

        table.on('toolbar(yhxx-table)', function (obj) {
            if (obj.event === 'refresh') {
                window.refresh();
            }
        });

        form.on('submit(yhxx-query)', function (data) {
            data.field.createTime = $("#createTime").val();
            console.log(JSON.stringify(data))
            table.reload('yhxx-table', {
                where: data.field
            })
            return false;
        });

        form.on('switch(yhxx-enable)', function (obj) {
            layer.tips(this.value + ' ' + this.name + '：' + obj.elem.checked, obj.othis);
        });

       /* window.retract = function (obj) {

            layer.confirm('确定要撤回本条消息吗？', {
                icon: 3,
                title: '提示'
            }, function (index) {
                layer.close(index);
                let loading = layer.load();
                $.ajax({
                    url: "/api/messages/retract/" + obj.data.fromID + "/" + obj.data.mid,
                    dataType: 'json',
                    success: function (result) {
                        layer.close(loading);
                        if (result.code == 0) {
                            layer.msg(result.msg, {
                                icon: 1,
                                time: 1000
                            }, function () {
                                table.reload('yhxx-table');
                            });
                        } else {
                            layer.msg(result.msg, {
                                icon: 2,
                                time: 1000
                            });
                        }
                    }
                })
            });
        }*/


        window.refresh = function (param) {
            table.reload('yhxx-table');
        }
    })
</script>
</body>

</html>